'----------------------------------------------
' Name: Ali Karbassi
' Date: January 25, 2007
' Description: Test 1
'              form frmJump
'----------------------------------------------

Public Class frmJump

   ''' <summary>
   ''' Calls ArrangeButtons and FontStyleButtons.
   ''' </summary>
   ''' <param name="sender"></param>
   ''' <param name="e"></param>
   ''' <remarks></remarks>
   Private Sub frmJump_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _
   MyBase.Resize

      ArrangeButtons()

   End Sub

   ''' <summary>
   ''' The sub displays all buttons on the form as required.
   ''' </summary>
   ''' <remarks>Done in 5 lines of code (not counting your 100 character limit wrap-arounds).</remarks>
   Friend Sub ArrangeButtons()

      Dim x As Integer = (Me.ClientSize.Height - (btnList.Count * btnSize.Height)) / (btnList.Count + 1)

      For Each key As String In btnList.Keys

         CType(btnList(key), Button).Left = (Me.ClientSize.Width / 2) - (btnSize.Width / 2)

         CType(btnList(key), Button).Top = x * (btnList.IndexOfKey(key) + 1) + (btnSize.Height * _
         btnList.IndexOfKey(key))

      Next

   End Sub

   ''' <summary>
   ''' Shows the new button's information.
   ''' </summary>
   ''' <param name="sender"></param>
   ''' <param name="e"></param>
   ''' <remarks>We love you Qi!</remarks>
   Friend Sub btnHandler(ByVal sender As System.Object, ByVal e As System.EventArgs)

      Dim key As String = btnList.GetKey(btnList.IndexOfValue(CType(sender, Button)))

      If CType(btnList(key), Button).Tag = 1 Then
         Dim caption As String = CType(sender, Button).Text

         MsgBox("My Key   : " & key & vbCrLf & "My Caption: " & caption, MsgBoxStyle.OkOnly)

         CType(btnList(key), Button).Left = CType(btnList(key), Button).Left - CType(btnList(key), Button).Width

         CType(btnList(key), Button).Tag = 2

      ElseIf CType(btnList(key), Button).Tag = 2 Then

         CType(btnList(key), Button).Left = CType(btnList(key), Button).Left + CType(btnList(key), Button).Width

         CType(btnList(key), Button).Tag = 3

      ElseIf CType(btnList(key), Button).Tag = 3 Then

         CType(btnList(key), Button).Left = CType(btnList(key), Button).Left + CType(btnList(key), Button).Width

         CType(btnList(key), Button).Tag = 4

      ElseIf CType(btnList(key), Button).Tag = 4 Then

         CType(btnList(key), Button).Left = CType(btnList(key), Button).Left - CType(btnList(key), Button).Width

         CType(btnList(key), Button).Tag = 1

      End If



   End Sub

   Private Sub BACKToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _
   BACKToolStripMenuItem.Click

      Me.Hide()
      frmButton.Show()

   End Sub

   Private Sub EXITToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _
   EXITToolStripMenuItem.Click

      Application.Exit()

   End Sub
End Class